<!doctype html>
<html lang="en">
<head>
    <title>Code coverage report for src/views/modules/sys/user-add-or-update.vue</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="..\..\..\..\prettify.css" />
    <link rel="stylesheet" href="..\..\..\..\base.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type='text/css'>
        .coverage-summary .sorter {
            background-image: url(..\..\..\..\sort-arrow-sprite.png);
        }
    </style>
</head>
<body>
<div class='wrapper'>
  <div class='pad1'>
    <h1>
      <a href="..\..\..\..\index.html">All files</a> / <a href="index.html">src/views/modules/sys</a> user-add-or-update.vue
    </h1>
    <div class='clearfix'>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Statements</span>
        <span class='fraction'>0/75</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Branches</span>
        <span class='fraction'>0/48</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Functions</span>
        <span class='fraction'>0/29</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Lines</span>
        <span class='fraction'>0/56</span>
      </div>
    </div>
  </div>
  <div class='status-line low'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181</td><td class="line-coverage quiet"><span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">&lt;<span class="cstat-no" title="statement not covered" >t<span class="fstat-no" title="function not covered" >em</span>plate&gt;</span>
  &lt;el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
<span class="cstat-no" title="statement not covered" >    :close-on-click-modal="false"</span>
    :visible.sync="visible"&gt;
    &lt;el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px"&gt;
      &lt;el-form-item label="用户名" prop="userName"&gt;
        &lt;el-inpu<span class="cstat-no" title="statement not covered" >t v-model="dataForm.userName</span>" placeholder="登录帐号"&gt;&lt;/el-input&gt;
      &lt;/el-form-item&gt;
<span class="cstat-no" title="statement not covered" >      &lt;el-form-item label="密码" prop="password" :class="{ 'is-required': !dataForm.id }"&gt;</span>
        &lt;el-input<span class="fstat-no" title="function not covered" > v-mo</span>del="dataForm.password" type="password" placeholder="密码"&gt;&lt;/el-input&gt;
      &lt;/el-form-<span class="cstat-no" title="statement not covered" >item&gt;</span>
      &lt;el-form-item label="确认密码" prop="comfirmPassword" :class="{ 'is-required': !dataForm.id }"&gt;
        &lt;el-input v-model="<span class="cstat-no" title="statement not covered" >dataForm.<span class="fstat-no" title="function not covered" >comfirmPassword" </span>type="password" placeholder="确认密码"&gt;&lt;/el-input&gt;</span>
<span class="cstat-no" title="statement not covered" >      &lt;/el-form-item&gt;</span>
      &lt;e<span class="cstat-no" title="statement not covered" >l-form-item label="邮箱" prop="em</span>ail"&gt;
        &lt;el-input v-model="dataForm.email" placeholder="邮箱"&gt;&lt;/el-input&gt;
      &lt;/<span class="cstat-no" title="statement not covered" >el-form-item</span>&gt;
      &lt;el-form-item label="手机号" prop="mobile"&gt;
        &lt;el-input v-model="dataForm.mobile" placeholder="手机号"&gt;&lt;/el-input&gt;
      &lt;/el-form-item&gt;<span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" ></span></span>
<span class="cstat-no" title="statement not covered" >      &lt;el-form-item label="角色" size="mini" prop="roleIdList"&gt;</span>
<span class="cstat-no" title="statement not covered" >        &lt;el-checkbox-group v-model="dataF</span>orm.roleIdList"&gt;
          &lt;el<span class="cstat-no" title="statement not covered" >-checkbox v-for="role in roleList" :key="role.roleId" :label="role.roleId"&gt;{{ role.roleName }}&lt;/el-checkbox&gt;</span>
<span class="cstat-no" title="statement not covered" >        &lt;/el-checkbox-group&gt;</span>
      &lt;/el-form-item&gt;
      &lt;e<span class="cstat-no" title="statement not covered" >l-form-item </span>label="状态" size="mini" prop="status"&gt;
        &lt;el-radio-group v-model="dataForm.status"&gt;
          &lt;el-radio :label="0"&gt;禁用&lt;/el-radio&gt;
          &lt;el-radio :lab<span class="cstat-no" title="statement not covered" >el="1"&gt;正常<span class="fstat-no" title="function not covered" >&lt;/el-radio&gt;</span></span>
<span class="cstat-no" title="statement not covered" >        &lt;/el-radio-group&gt;</span>
      &lt;/<span class="cstat-no" title="statement not covered" >el-form-item&gt;</span>
    &lt;/el-form&gt;
    &lt;spa<span class="cstat-no" title="statement not covered" >n slot="foot</span>er" class="dialog-footer"&gt;
      &lt;el-button @click="visible = false"&gt;取消&lt;/el-button&gt;
      &lt;el-button type="primary" @click="dataFormSubmit()"&gt;确定&lt;/el-button&gt;
    &lt;/span&gt;<span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" ></span></span>
  &lt;/el<span class="cstat-no" title="statement not covered" >-dialog&gt;</span>
&lt;/templa<span class="cstat-no" title="statement not covered" >te&gt;</span>
&nbsp;
&lt;script&gt;<span class="cstat-no" title="statement not covered" ></span>
  import { isEmail, isMobile } from '@/utils/validate'
  export default {
<span class="cstat-no" title="statement not covered" >    data () {</span>
      var validatePassword = (rule, value, callback) =&gt; {
        if (!this.dataForm.id &amp;&amp; !/\S/.test(value)) {
          callback(new Error('密码不能为空'))
        } else {
          callback()
        }
      }
      var validateComfirmPassword = (rule, value, callback) =&gt; {
        if (!this.dataForm.id &amp;&amp; !/\S/.test(value)) {
          callback(new Error('确认密码不能为空'))
        } else if (this.dataForm.password !== value) {
          callback(new Error('确认密码与密码输入不一致'))
        } else {
          callback()
        }
      }
      var validateEmail = (rule, value, callback) =&gt; {
        if (!isEmail(value)) {
          callback(new Error('邮箱格式错误'))
        } else {
          callback()
        }
      }
      var validateMobile = (rule, value, callback) =&gt; {
        if (!isMobi<span class="fstat-no" title="function not covered" >le(va</span>lue)) {
          callback(<span class="cstat-no" title="statement not covered" >new E</span>rror('手机号格式错误'))
        } else {
<span class="cstat-no" title="statement not covered" >          callback()</span>
<span class="cstat-no" title="statement not covered" >        }</span>
      }
      return {
        visible: false,
        roleLi<span class="fstat-no" title="function not covered" >st</span>: [],
        dataForm: {<span class="cstat-no" title="statement not covered" ></span>
          id: 0,
<span class="cstat-no" title="statement not covered" >          userName: '',</span>
          pass<span class="fstat-no" title="function not covered" >wo</span>rd: '',
<span class="cstat-no" title="statement not covered" >          comfirmPassword: '',</span>
<span class="cstat-no" title="statement not covered" >          salt: '',<span class="fstat-no" title="function not covered" ></span></span>
<span class="cstat-no" title="statement not covered" >          email: '',</span>
          mobile: '',
          role<span class="fstat-no" title="function not covered" >Id</span>List: [],
<span class="cstat-no" title="statement not covered" >          status: 1</span>
        },<span class="cstat-no" title="statement not covered" ></span>
        dataRule: {
          userName: [
            { required: true, message: '用户名不能为空', trigger: 'blur' }
          ],<span class="fstat-no" title="function not covered" ></span>
          password: [<span class="cstat-no" title="statement not covered" ></span>
            { validator: validatePassword, trigger: 'blur' }
          ],<span class="cstat-no" title="statement not covered" ></span>
          comf<span class="cstat-no" title="statement not covered" >irmPassword: [</span>
            { <span class="cstat-no" title="statement not covered" >validator: validateComfirmPassword, tri</span>gger: 'blur' }
          ],<span class="cstat-no" title="statement not covered" ></span>
          emai<span class="cstat-no" title="statement not covered" >l: [</span>
            { <span class="cstat-no" title="statement not covered" >required: true, message: '邮箱不能为空', trigger: 'blur' </span>},
            { <span class="cstat-no" title="statement not covered" >validator: validateEmail, trigger: 'blur' }</span>
          ],
          mobile: [
            { required: true, message: '手机号不能为空', trigger: 'blur' },
            { validator: validateMobile, trigger: 'blur' }
          ]
        }
      }
    },<span class="fstat-no" title="function not covered" ></span>
    methods: {<span class="cstat-no" title="statement not covered" ></span>
      init (id) {
<span class="cstat-no" title="statement not covered" >        this.dataForm.id = id || 0<span class="fstat-no" title="function not covered" ></span></span>
<span class="cstat-no" title="statement not covered" >        this.$http({</span>
<span class="cstat-no" title="statement not covered" >          url: this.$http.adornUrl('/sys/role/select'),</span>
          method: 'get',
          params: this.$http.adornParams()
        }).then(({data}) =&gt; {
          this.roleList = data &amp;&amp; data.code === 0 ? data.list : []
        }).then(() =&gt; {
          this.visible = true
          this.$nextTick(() =&gt; {
            this.$refs['dataForm'].resetFields()
          })
        }).then(() =&gt; {
          if (this.dataForm.id) {
            this.$http({
              url:<span class="fstat-no" title="function not covered" > t</span>his.$http.adornUrl(`/sys/user/info/${this.dataForm.id}`),
              method: '<span class="cstat-no" title="statement not covered" >get',</span>
              params: this.$http.adornParams()
<span class="cstat-no" title="statement not covered" >            }).then(({data}) =&gt; {</span>
<span class="cstat-no" title="statement not covered" >              if (data &amp;&amp; data.code === 0) {</span>
                this.dataForm.userName = data.user.username
                this.dataForm.salt = data.user.salt
                this.dataForm.email = data.user.email
                this.dataForm.mobi<span class="fstat-no" title="function not covered" >le = dat</span>a.user.mobile
                th<span class="cstat-no" title="statement not covered" >is.dataForm.roleIdList =</span> data.user.roleIdList
                th<span class="cstat-no" title="statement not covered" >is.dataForm.status = data.user.st</span>atus
              }
            })
          }
        })<span class="cstat-no" title="statement not covered" ></span>
      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) =&gt; {
          if (valid) {
            this.$http({
              url: this.$http.adornUrl(`/sys/user/${!this.dataForm.id ? 'save' : 'update'}`),
              method: 'post',
              data: this.$http.adornData({
                'userId': this.dataForm.id || undefined,
                'username': this.dataForm.userName,
                'password': this.dataForm.password,
                'salt': this.dataForm.salt,
                'email': this.dataForm.email,
                'mobile': this.dataForm.mobile,
                'status': this.dataForm.status,
                'roleIdList': this.dataForm.roleIdList
              })
            }).then(({data}) =&gt; {
              if (data &amp;&amp; data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () =&gt; {
                    this.visible = false
                    this.$emit('refreshDataList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    }
  }
&lt;/script&gt;
&nbsp;</pre></td></tr>
</table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
  Code coverage
  generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Sep 20 2018 10:14:21 GMT+0800 (中国标准时间)
</div>
</div>
<script src="..\..\..\..\prettify.js"></script>
<script>
window.onload = function () {
        if (typeof prettyPrint === 'function') {
            prettyPrint();
        }
};
</script>
<script src="..\..\..\..\sorter.js"></script>
</body>
</html>
